import type { UserInfoType } from "@/store/modules/types";
import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
export interface OrganizationTreeNode {
  id: number;
  name: string;
  children?: OrganizationTreeNode[];
  remark: string;
}
export interface UserInfo {
  name: string;
  telephone: string;
  email: string;
}
export interface SystemPlatformInfo {
  frameworkDescription: string;
  osDescription: string;
  osVersion: string;
  osArchitecture: string;
  machineName: string;
  version: string;
}
/** 登录 */
export const login = async (data?: object) => {
  return http.request<UserInfoType>("post", baseUrlApi("loginMerchants"), {
    data
  });
};
// 用户信息
export const getInfo = async (data?: object) => {
  return http.request<UserInfoType>("get", baseUrlApi("getInfo"), { data });
};
/** 获取权限 */
export const getUserPermissions = async () => {
  return http.request<string[]>("get", "/api/getInfo");
};
/** 获取登录图片验证码 */
export const getcaptchaImage = async () => {
  return http.request<any>("get", baseUrlApi("captchaImage"));
  // return http.get(baseUrlApi("captchaImage"));
};
/** 获取短信验证码 */
export const getcaptchaCode = async (username: any) => {
  return http.request<any>("get", baseUrlApi("system/captcha/captchaSMS"));
  // return http.get(baseUrlApi("captchaImage"));
};

/** 获取组织机构 */
export const getOrganizationTreeData = () => {
  return http.request<OrganizationTreeNode[]>("get", "/auth/organization-tree");
};

export const getUserInfo = (password: string) => {
  return http.request<UserInfo>("get", "/auth/user-info", {
    params: { password: password }
  });
};
export const editUserInfo = (params: any) => {
  return http.request<UserInfo>("put", "/api/system/user/profile/updatePwd", {
    params
  });
};
export const getSystemPlatformInfo = () => {
  return http.request<SystemPlatformInfo>(
    "get",
    "/auth/system-platform-info",
    {}
  );
};

export const getUnReadNotice = () => {
  return http.request("get", "/auth/unread-notice");
};
// 商务端商户列表
export function listMerchantName(params?) {
  return http.request(
    "get",
    baseUrlApi("business/user_data_permissions/listMerchantName"),
    { params }
  );
}
// 商务端服务公司列表
export function listTaxSourcesRoleN(params?) {
  return http.request(
    "get",
    baseUrlApi("business/user_data_permissions/listTaxSourcesRoleN"),
    { params }
  );
}
